﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DSL
{
    public interface SyntaxUnit
    {
        string GetId();
        int GetType();
        int GetLine();
        string ToScriptString();
    }

    public abstract class AbstactSyntaxUnit:SyntaxUnit
    {
        public const int VALUE_DATA = 0;
        public const int FUNCTION_CALL_DATA = 0;
        public const int FUNCTION_DATA = 0;
        public const int STATEMENT_DATA = 0;

        public abstract string GetId();
        public abstract int GetType();
        public abstract int GetLine();
        public abstract string ToScriptString();
    }

    public class ValueData : AbstactSyntaxUnit
    {
        private string m_Id;
        private int m_Line;

        private bool m_IsString;
        private string m_String;
        private bool m_IsNum;
        private double m_Num;
        private bool m_IsBool;
        private bool m_Bool;

        public void SetId(string Id)
        {
            this.m_Id = Id;
        }

        public void SetLine(int line)
        {
            this.m_Line = line;
        }

        public override string GetId()
        {
            return m_Id;
        }

        public override int GetType()
        {
            return VALUE_DATA;
        }

        public override int GetLine()
        {
            return m_Line;
        }

        public void SetString(string value)
        {
            this.m_IsString = true;
            this.m_IsBool = false;
            this.m_IsNum = false;

            this.m_String = value;
        }

        public void SetNum(string value)
        {
            this.m_IsString = false;
            this.m_IsBool = false;
            this.m_IsNum = true;

            this.m_String = value;
        }

        public void SetBool(bool value)
        {
            this.m_IsString = false;
            this.m_IsBool = true;
            this.m_IsNum = false;

            this.m_Bool = value;
        }

        public bool IsString()
        {
            return m_IsString;
        }

        public bool IsNum()
        {
            return m_IsNum;
        }

        public bool IsBool()
        {
            return m_IsBool;
        }

        public string GetString()
        {
            return m_String;
        }

        public double GetNum()
        {
            return m_Num;
        }

        public bool GetBool()
        {
            return m_Bool;
        }

        public override string ToScriptString()
        {
            throw new NotImplementedException();
        }
    }

    public class FunctionCallData : AbstactSyntaxUnit
    {
        private string m_Id;
        private int m_Line;

        private List<ValueData> m_paramList;

        public FunctionCallData()
        {
            m_paramList = new List<ValueData>();
        }

        public void AddValueData(ValueData data)
        {
            m_paramList.Add(data);
        }

        public void SetId(string Id)
        {
            this.m_Id = Id;
        }

        public void SetLine(int line)
        {
            this.m_Line = line;
        }

        public override string GetId()
        {
            return m_Id;
        }

        public override int GetType()
        {
            return FUNCTION_CALL_DATA;
        }

        public override int GetLine()
        {
            return m_Line;
        }

        public override string ToScriptString()
        {
            throw new NotImplementedException();
        }
    }

    public class FunctionData : AbstactSyntaxUnit
    {
        private string m_Id;
        private int m_Line;

        private FunctionCallData m_CallData;
        private List<StatementData> m_StatementList;

        public FunctionData()
        {
            m_StatementList = new List<StatementData>();
        }

        public void SetFunctionCallData(FunctionCallData data)
        {
            this.m_CallData = data;
        }

        public void AddStatement(StatementData data)
        {
            this.m_StatementList.Add(data);
        }

        public void SetId(string Id)
        {
            this.m_Id = Id;
        }

        public void SetLine(int line)
        {
            this.m_Line = line;
        }

        public override string GetId()
        {
            return m_Id;
        }

        public override int GetType()
        {
            return FUNCTION_CALL_DATA;
        }

        public override int GetLine()
        {
            return m_Line;
        }

        public override string ToScriptString()
        {
            throw new NotImplementedException();
        }
    }

    public class StatementData : AbstactSyntaxUnit
    {
        private string m_Id;
        private int m_Line;

        public StatementData()
        {
            
        }

        public void SetFunctionData(FunctionData data)
        {
            this.m_FunctionData = data;
        }

        private FunctionData m_FunctionData;

        public void SetId(string Id)
        {
            this.m_Id = Id;
        }

        public void SetLine(int line)
        {
            this.m_Line = line;
        }

        public override string GetId()
        {
            return m_Id;
        }

        public override int GetType()
        {
            return FUNCTION_CALL_DATA;
        }

        public override int GetLine()
        {
            return m_Line;
        }

        public override string ToScriptString()
        {
            throw new NotImplementedException();
        }
    }

    class ScriptableData
    {
    }
}
